////////////////////////////////////////////////////////
// 电动车-夸父-3米钢架版 ev-kuafu-3m-steel
// Time-stamp: <此文《ev-kuafu-201909.scad》于 2021-01-11 13:45:13 被黑传说在[atlas@jobinson]上修改>
///////////////////////////////////////////////////////

use <libs/formed-material/formed-material.scad>
use <libs/formed-material/formed-link.scad>
include <libs/material-color.scad>

module material_use () {
     // 所用材料
}


module framework_bottom () {
     // 主轴
     translate([0,250,250]) rotate([0,90,0]) formed_C(height = 150,flange_height=60,flange_width=20, thickness = 2, length = 3000);

     translate([3000,-250,250]) rotate([180,90,0]) formed_C(height = 150,flange_height=60,flange_width=20, thickness = 2, length = 3000);

     // 前翼
     translate([0,650,250])  rotate([90,90,0]) formed_U(height = 150,flange_height=60, thickness = 2, length = 1300);
     
     // 后翼
     translate([3000,-650,250])  rotate([-90,90,0]) formed_U(height = 150,flange_height=60, thickness = 2, length = 1300);  
     
// 前-中 连接  
     translate([10,-660,300]) rotate([0,90,0]) formed_C(height = 100,flange_height=40,flange_width=20, thickness = 2, length = 800);
     
     translate([800,660,300]) rotate([180,90,0]) formed_C(height = 100,flange_height=40,flange_width=20, thickness = 2, length = 800);
    
// 中部外翼
     translate([800,-660,50]) rotate([0,90,0]) formed_C(height = 100,flange_height=40,flange_width=20, thickness = 2, length = 1300);
     
     translate([2100,660,50]) rotate([180,90,0]) formed_C(height = 100,flange_height=40,flange_width=20, thickness = 2, length = 1300);
     
// 中部外翼支撑架 
     translate([800,650,50])  rotate([90,90,0]) formed_U(height = 100,flange_height=40, thickness = 2, length = 1300);
     translate([2100,-650,50])  rotate([-90,90,0]) formed_U(height = 100,flange_height=40, thickness = 2, length = 1300); 
     
     
}

// 车身
module framework_stand () {
     // 立架
     translate([800,-720,0]) rotate([0,0,0]) formed_C(height = 80,flange_height=30,flange_width=20, thickness = 2, length = 400);
     translate([870,720,0]) rotate([0,0,180]) formed_C(height = 80,flange_height=30,flange_width=20, thickness = 2, length = 400);
    
     translate([1800,-720,0]) rotate([0,0,0]) formed_C(height = 80,flange_height=30,flange_width=20, thickness = 2, length = 1100);
     translate([1870,720,0]) rotate([0,0,180]) formed_C(height = 80,flange_height=30,flange_width=20, thickness = 2, length = 1100);    
    
}

module framework_front () {
     // 前立架
     translate([25,730,150]) rotate([0,0,-90]) bar_angle_equal(28,2.5,400);
     translate([25,-720,150])  bar_angle_equal(28,2.5,400);
}

module framework_back () {
     // 后立架
     translate([2975,730,150]) rotate([0,0,-180]) bar_angle_equal(28,2.5,500);
     translate([2975,-720,150]) rotate([0,0,90]) bar_angle_equal(28,2.5,500);
}

// 车内
module framework_body() {
    
     // 操作台架
     translate([800,-650,500])  rotate([-90,90,0]) formed_U(height = 100,flange_height=40, thickness = 2, length = 1300);    
// 仪表架
          
     module seat_base() {
	  // 椅腿   
	  translate([0,0,0]) rotate([0,0,-90]) bar_angle_equal(40,3.5,230);
	  translate([330,0,0]) rotate([0,0,180]) bar_angle_equal(40,3.5,230);
	  translate([0,-700,0]) bar_angle_equal(40,3.5,230);
	  translate([330,-700,0]) rotate([0,0,90]) bar_angle_equal(40,3.5,230);  

          // 下凹吊式
// 驾驶安装座    
	  translate([0,0,230]) rotate([90,90,0])bar_angle_equal(40,3.5,700);
	  translate([330,-700,230]) rotate([-90,90,0]) bar_angle_equal(40,3.5,700);
    
	  translate([330,0,230]) rotate([180,90,0]) bar_angle_equal(40,3.5,330);    
	  translate([0,-260,230]) rotate([0,90,0]) bar_angle_equal(40,3.5,330);  
    
	  translate([330,-440,230]) rotate([180,90,0]) bar_angle_equal(40,3.5,330);
	  translate([0,-700,230]) rotate([0,90,0]) bar_angle_equal(40,3.5,330); 
  
     }

     // translate([1140, 350, 120]) seat_base();


     
}

// 车顶棚
module framework_top() {
     translate([0,1200,0]) rotate([90,0,0]) bar_angle_equal(28,2.5,1200);
     translate([0,1200,0]) rotate([180,-90,0]) bar_angle_equal(28,2.5,2100);
     translate([2100,1200,0]) rotate([90,-90,0]) bar_angle_equal(28,2.5,1200);
     translate([2100,0,0]) rotate([180,-90,180])bar_angle_equal(28,2.5,2100);
}


// 外壳
module shell () {
     // 车底板
     % translate([0,-650,100]) cube([3000,1300,10]); 
    
     // 车前墙
     translate([0,-650,100]) rotate([0,-90,0]) cube([400,1300,10]); 

     // 车前盖和迎风玻璃
     % translate([0,0,500]) rotate([0,-30,0]) cube([1300,650,10]);
     % translate([0,-650,500]) rotate([0,-30,0]) cube([1300,650,10]);
    
// 围襟     
     % translate([0,-650,100]) cube([3000,10,400]); 
     % translate([0,650,100]) cube([3000,10,400]);
    
     // 车门
    
    
// 车后盖
     % translate([1100,-700,1300])  rotate([0,20,0]) cube([2000,1400,10]); 
    
     // 太阳能电板
     color("grey") translate([1100,-650,1400]) rotate([0,20,0]) cube([1200,550,30]);
     color("grey") translate([1100,60,1400]) rotate([0,20,0]) cube([1200,550,30]);
     color("grey") translate([1900,-650,1050]) rotate([0,20,0]) cube([1200,550,30]);
     color("grey") translate([1900,60,1050]) rotate([0,20,0]) cube([1200,550,30]);  
    
     // 车后墙
     translate([3000,-700,100]) rotate([0,-90,0]) cube([400,1400,10]);  
    
}



// 部件
module parts () {
    
     // 电池组
     module battery_pack () {
	  cube([400,600,200]);
     }
     translate([1500,-300,20]) battery_pack();    
    
     // 方向盘
     module control_wheel () {
	  rotate_extrude (angle=360) translate([200,0,0]) circle(10);
	  rotate([90,0,-30]) cylinder(200, 20,10);
	  rotate([90,0,80]) cylinder(200, 20,10);
	  rotate([90,0,-160]) cylinder(200, 20,10);
	  cylinder(10,50,50);
     }

     translate([400,-100, -100]) rotate([0,36,-18]) cylinder(450,30,25);
     translate([670,-190, 280]) rotate([0,50,-18]) cylinder(450,25,17);
     translate([1000,-295,570]) rotate([0,50,0]) control_wheel();  


     // 仪表盘
     
     // 操作台
     
     module seat () {
// 驾驶座
	  translate([0,0,230]) rotate([90,90,0]) bar_angle_equal(40,3.5,260);
	  rotate([0,90,0]) translate([-230,0,0]) rotate([0,0,-90]) bar_angle_equal(40,3.5,330);
	  rotate([90,90,0]) translate([-230,330,0]) rotate([0,0,-90]) bar_angle_equal(40,3.5,260);
	  rotate([0,90,0]) translate([-230,-260,0]) bar_angle_equal(40,3.5,330);
    
	  translate([0,-300,250]) cube([400,400,100]);
	  translate([400,-300,250]) rotate([100,0,90]) cube([400,700,100]);

     }

     module seat_sub () {
// 副座
	  rotate([90,90,0]) translate([-230,0,0]) bar_angle_equal(28,2.5,260);
	  rotate([0,90,0]) translate([-230,0,0]) rotate([0,0,-90]) bar_angle_equal(28,2.5,330);
	  rotate([90,90,0]) translate([-230,330,0]) rotate([0,0,-90])  bar_angle_equal(28,2.5,260);
	  rotate([0,90,0]) translate([-230,-260,0]) bar_angle_equal(28,2.5,330);
    
	  translate([0,-300,250]) cube([400,400,100]);
	  translate([400,-300,250]) rotate([100,0,90]) cube([400,700,100]);
    
     }
   
     translate([1140, -100, 60]) seat();
     translate([1140, 400, 60]) seat_sub();     
    
// 轮子
     module wheel() {
	  rotate([90,0,0]) cylinder(240,240,240);
     }
     translate([400,710,-110]) wheel();
     translate([400,-450,-110]) wheel();
     translate([2500,710,-110]) wheel();
     translate([2500,-450,-110]) wheel();
     translate([400,640,-110]) rotate([90,0,0])cylinder(1300,25,25);
     translate([2500,640,-110])  rotate([90,0,0]) cylinder(1300,25,25);

}



/////////////////////////////////////////
// Test
////////////////////////////////////////

module framework() {
     framework_bottom();
     framework_stand();
     framework_front();
     framework_body();
     framework_back();
     translate([1100,-650,1500]) rotate([0,20,0]) framework_top();    
}

module car() {
// 比例尺 1：10
     color("black") framework();
     
     shell();

     % parts();
    
}

scale([0.1,0.1,0.1]) car();

// % scale([0.5,0.5,0.5]) material_use();


